package jp.co.ikd.iBatis;

import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.ibatis.sqlmap.client.SqlMapSession;

public class iBatis {

	public static SqlMapSession getSession() {

		Resources.setCharset(Charset.forName("UTF-8"));

		Reader readerOracle = null;

		try {
			readerOracle = Resources.getResourceAsReader("ikdSqlMapConfig.xml");
		} catch (IOException e) {
			System.err.println("sqlMapConfig読めないよ。");
			e.printStackTrace();
			return null;
		}

		SqlMapClient sqlMapClient = SqlMapClientBuilder
				.buildSqlMapClient(readerOracle);

		return sqlMapClient.openSession();
	}
}
